package script.prefabScript
{
	import eventUtil.EventCenter;
	
	import laya.components.Script;
	import laya.events.Event;
	import laya.ui.Label;
	
	public class BookContents extends Script
	{
		/** @prop {name:pageNum,tips:"目录对应的页码",type:int}*/
		public var pageNum:int = 1;
		private var txt:Label;
		public function BookContents()
		{
			super();
		}
		
		override public function onStart():void
		{
			txt = this.owner as Label;
			
			txt.on(Event.MOUSE_OVER,this,showBackground);
			txt.on(Event.MOUSE_OUT,this,hideBackground);
			
			txt.on(Event.CLICK,this,onGotoPage);

		}
		
		private function onGotoPage():void
		{
			EventCenter.instance.event(EventCenter.OPEN_BOOK_PAGE,pageNum);
		}
		private function showBackground():void
		{
			txt.bgColor = "#889988";
			
		}
		private function hideBackground():void
		{
			txt.bgColor = "";
			
		}
	}
}